<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/1/4
  Time: 19:13
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt" %>
<head>
    <meta charset="UTF-8">
    <title>上海营创</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <meta http-equiv="Content-Type" content="text/html" charset="utf-8"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/font.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/xadmin.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/lib/layui/css/layui.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <script src="${pageContext.request.contextPath}/js/jquery-1.10.2.min.js"></script>
</head>
<body>
<%--展示项目基础信息开始--%>
<div class="layui-card-body layui-table-body layui-table-main layui-col-lg12">
    <fieldset class="layui-elem-field layuimini-search">
        <legend>项目基础信息</legend>
        <div style="margin: 10px 10px 10px 10px">
            <form class="layui-form layui-form-pane" action="" id="projectBaseInfoForm"
                  lay-filter="projectBaseInfoForm">
                <div class="layui-form-item">
                    <label class="layui-form-label">项目编号</label>
                    <div class="layui-input-inline">
                        <div class="layui-input-inline">
                            <input type="text" name="PO_PRJCODE" autocomplete="off" class="layui-input"
                                   value="${orders.PO_PRJCODE}" id="PO_PRJCODE">
                        </div>
                    </div>

                    <label class="layui-form-label">订单编号</label>
                    <div class="layui-input-inline">
                        <div class="layui-input-inline">
                            <input type="text" name="PO_ID" autocomplete="off" class="layui-input"
                                   value="${orders.PO_ID}">
                        </div>
                    </div>

                    <label class="layui-form-label">订单名称</label>
                    <div class="layui-input-inline">
                        <div class="layui-input-inline">
                            <input type="text" name="PO_NAME" autocomplete="off" class="layui-input"
                                   value="${orders.PO_NAME}">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">合同金额</label>
                    <div class="layui-input-inline">
                        <input type="text" name="PO_SUMS" autocomplete="off" class="layui-input"
                               value="${orders.PO_SUMS}">
                    </div>
                    <label class="layui-form-label">账期</label>
                    <div class="layui-input-inline">
                        <input type="text" name="PO_During" autocomplete="off" class="layui-input"
                               value="${orders.PO_During}">
                    </div>
                    <label class="layui-form-label">结算方式</label>
                    <div class="layui-input-inline">
                        <input type="text" name="PO_HowToPay" autocomplete="off" class="layui-input"
                               value="${orders.PO_HowToPay}">
                    </div>
                    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
                       onclick="location.reload()" title="刷新">
                        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
                    </a>
                </div>
            </form>
        </div>
    </fieldset>
</div>
<%--</div>--%>
<%--展示项目基础信息结束--%>

<%--<hr style="border: 1px solid"/>--%>
<div class="layui-card-body layui-table-body layui-table-main layui-col-lg12">
    <%--展示项目基础信息开始--%>
    <%--<div class="layui-card-body layui-table-body layui-table-main layui-col-lg12">--%>
    <div class="layui-card-body layui-table-body layui-table-main layui-col-lg6">
        <fieldset class="layui-elem-field layuimini-search">
            <legend>应收款项</legend>
            <div style="margin: 10px 10px 10px 10px">
                <table class="layui-hide" id="KWList" lay-filter="KWList"></table>
                <script type="text/html" id="barDemo">
                    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="addKW">添加款项</a>
                    <%--<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="detail">查看款项</a>
                    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑金额</a>--%>
                </script>
            </div>
        </fieldset>
    </div>

    <div class="layui-card-body layui-table-body layui-table-main layui-col-lg6">
        <fieldset class="layui-elem-field layuimini-search">
            <legend>收款任务</legend>
            <div style="margin: 10px 10px 10px 10px">
                <table class="layui-hide" id="KWTask" lay-filter="KWTask"></table>
                <script type="text/html" id="barDemo1">
                    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="addTask">添加</a>
                    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="checkTask">查看</a>
                    <%--<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="detail">查看款项</a>
                    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑金额</a>--%>
                </script>
            </div>
        </fieldset>
    </div>
</div>

<div class="layui-card-body layui-table-body layui-table-main layui-col-lg12">
    <fieldset class="layui-elem-field layuimini-search" style="height: 80%">
        <legend>添加款项</legend>
        <div style="margin: 10px 10px 10px 10px">
            <form class="layui-form layui-form-pane" action="" id="KWForm"
                  lay-filter="KWForm">
                <div class="layui-form-item">
                    <label class="layui-form-label">项目编号</label>
                    <div class="layui-input-inline">
                        <div class="layui-input-inline">
                            <input type="text" name="PO_PRJCODE" autocomplete="off" class="layui-input"
                                   value="${orders.PO_PRJCODE}">`
                        </div>
                    </div>

                    <label class="layui-form-label">订单编号</label>
                    <div class="layui-input-inline">
                        <div class="layui-input-inline">
                            <input type="text" name="PO_ID" autocomplete="off" class="layui-input"
                                   value="${orders.PO_ID}">
                        </div>
                    </div>
                    <label class="layui-form-label">款项类型</label>
                    <div class="layui-input-inline">
                        <div class="layui-input-inline">
                            <select name="KW_CLASS" class="KW_CLASSSelect" lay-filter="selectCLASS">
                                <option value="">请选择类型</option>
                            </select>
                        </div>
                    </div>
                    <label class="layui-form-label">款项名称</label>
                    <div class="layui-input-inline">
                        <div class="layui-input-inline">
                            <select name="KW_NAME" class="KW_NAMESelect">
                            </select>
                        </div>
                    </div>
                    <label class="layui-form-label">款型金额</label>
                    <div class="layui-input-inline">
                        <div class="layui-input-inline">
                            <input type="text" name="KW_MONEY" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-input-inline">
                        <a class="layui-btn " lay-submit="" lay-filter="add-KW-btn">添加款项</a>
                    </div>
                </div>
            </form>
        </div>
    </fieldset>
</div>

<%--添加款项任务的弹出层开始--%>
<div id="addKWTask" style="display: none;padding: 0.3125rem">
    <form method="post" class="layui-form layui-form-pane" lay-filter="KWTaskForm" id="KWTaskForm">
        <%--<div class="layui-form-item">
            &lt;%&ndash;<input type="hidden" name="usId" id="usId"/>&ndash;%&gt;
            <div class="layui-inline">
                <label class="layui-form-label">项目号</label>
                <div class="layui-input-inline">
                    <input type="text" name="TK_PRJCode" id="TK_PRJCode" lay-verify="required" autocomplete="off"
                           placeholder="请输入用户名" class="layui-input" value="${orders.PO_PRJCODE}">
                </div>
            </div>

            <input type="hidden" name="usPassword" id="usPassword" lay-verify="required" autocomplete="off"
                           placeholder="任务类型" class="layui-input" value="PMT">

            <div class="layui-inline">
                <label class="layui-form-label">真实姓名</label>
                <div class="layui-input-inline">
                    <input type="text" name="usName" id="usName" lay-verify="required" autocomplete="off"
                           placeholder="请输入真实姓名" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">英文名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="usEngName" id="usEngName"
                           autocomplete="off" placeholder="请输入英文名称" class="layui-input">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">身份证号</label>
                <div class="layui-input-inline">
                    <input type="text" name="usIdcardNo" id="usIdcardNo" lay-verify="required"
                           autocomplete="off" placeholder="请输入身份证号" class="layui-input">
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">电话号码</label>
                <div class="layui-input-inline">
                    <input type="text" name="usMobilePhone" id="usMobilePhone" lay-verify="required"
                           autocomplete="off" placeholder="请输入电话号码" class="layui-input">
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">邮箱地址</label>
                <div class="layui-input-inline">
                    <input type="text" name="usEmail" id="usEmail"
                           autocomplete="off" placeholder="请输入邮箱地址" class="layui-input">
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">薪水</label>
                <div class="layui-input-inline">
                    <input type="text" name="usSalary" id="usSalary" lay-verify="required"
                           autocomplete="off" placeholder="请输入薪水" class="layui-input">
                </div>
            </div>
        </div>


        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">性别</label>
                <div class="layui-input-inline">
                    <select name="usGender" id="usGender">
                        <option value="男" selected>男</option>
                        <option value="女">女</option>
                    </select>
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">学历</label>
                <div class="layui-input-inline">
                    <select name="usEducation" id="usEducation">
                        <option disabled="" selected="">请选择学历</option>
                        <option value="专科">专科</option>
                        <option value="本科">本科</option>
                        <option value="研究生">研究生</option>
                        <option value="博士">博士</option>
                    </select>
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block" style="text-align: center;">
                <a class="layui-btn " lay-submit="" lay-filter="doAddOrUpdateEmployee"><label
                        class="layui-icon layui-icon-release"></label>提交</a>
                <a class="layui-btn layui-btn-warm" onclick="javascript:$('#employeesForm')[0].reset()"
                   lay-filter="data-search-btn"><label class="layui-icon layui-icon-refresh"></label>重置</a>
            </div>
        </div>--%>
        <table class="layui-hide" id="KW_NAMELIST" lay-filter="KW_NAMELIST"></table>
        <script type="text/html" id="barDemo2">
            <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="confirm">添加</a>
            <%--<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="detail">查看款项</a>
            <a class="layui-btn layui-btn-xs" lay-event="edit">编辑金额</a>--%>
        </script>
    </form>
</div>
<%--添加款项任务的弹出层结束--%>


<%--展示项目基础信息结束--%>
<%--<hr style="border: 1px solid"/>--%>

<%--展示所有款项--%>

<%--<div class="layui-fluid layui-col-lg12" style=" margin-top: 10px">
    <div class="box-header with-border">
        <i class="fa fa-cube"></i>
        <h3 class="box-title" style="color: red">任务展示</h3>
    </div>
    <iframe src='/Task/AllTaskQuestion' frameborder="0" scrolling="auto" class="x-iframe layui-col-xs12"
            height="100%"
            style="overflow-x:scroll">
    </iframe>
</div>--%>
</body>
</html>
<script type="text/html" id="ProjectSituationStyle">
    {{#  if(d.tk_CODE === 'P1'){ }}
    <span style="color: #F581B1;">{{ d.tk_CODE}}</span>
    {{#  } else if(d.prj_SITUATION === '已终验'){ }}
    <span style="color: green;">{{ d.prj_SITUATION}}</span>
    {{#  } }}
    {{#  if(d.prj_SITUATION === '进行中'){ }}
    <span style="color: red;">{{ d.prj_SITUATION}}</span>
    {{#  } else { }}
    {{#  } }}
</script>
<script>
    layui.use(['table', 'form', 'laydate'], function () {
        var table = layui.table;
        var form = layui.form;
        var laydate = layui.laydate;
        // 定义数据表格
        var tableIns = table.render({
            elem: '#KWList',
            url: '/KW/KWTable',
            //toolbar: 'default', //  默认的头工具栏事件
            cellMinWidth: 110, //全局定义常规单元格的最小宽度，layui 2.2.1 新增
            cols: [
                [{
                    field: 'kw_CODE',
                    title: '款项编号',
                    align: "center",
                    width: "25%"
                },
                    {
                        field: 'kw_CLASS',
                        title: '款项名称',
                        align: "center",
                        width: "25%"
                    },
                    {
                        field: 'kw_MONEY',
                        title: '款项金额',
                        align: "center",
                        edit: "text",
                        width: "25%"
                    },
                    /*{
                        field: 'kw_NOTES',
                        title: '总额比例',
                        align: "center",
                        width: "20%"
                    },*/
                    {
                        fixed: 'right',
                        title: '操作',
                        width: "25%",
                        align: 'center',
                        toolbar: '#barDemo'
                    }
                ]
            ]
        });


        var KWTaskTable = table.render({
            elem: '#KWTask',
            url: '/KW/KWTask/${orders.PO_PRJCODE}',
            //toolbar: 'default', //  默认的头工具栏事件
            cellMinWidth: 110, //全局定义常规单元格的最小宽度，layui 2.2.1 新增
            cols: [
                [{
                    field: 'pay_PRJCODE',
                    title: '项目编号',
                    align: "center",
                    width: "15%"
                },
                    {
                        field: 'pay_ID',
                        title: '款项ID',
                        align: "center",
                        width: "10%"
                    },
                    {
                        field: 'pay_CODE',
                        title: '款项编号',
                        align: "center",
                        edit: "text",
                        width: "15%"
                    },
                    {
                        field: 'pay_NAME',
                        title: '款项名称',
                        align: "center",
                        edit: "text",
                        width: "15%"
                    },
                    {
                        field: 'pay_AMOUNT',
                        title: '款项金额',
                        align: "center",
                        edit: "text",
                        width: "15%"
                    },
                    {
                        field: 'pay_ARRIVED_AMOUNT',
                        title: '实际到账金额',
                        align: "center",
                        edit: "text",
                        width: "15%"
                    },
                    /*{
                        field: 'kw_NOTES',
                        title: '总额比例',
                        align: "center",
                        width: "20%"
                    },*/
                    {
                        fixed: 'right',
                        title: '操作',
                        width: "15%",
                        align: 'center',
                        toolbar: '#barDemo1'
                    }
                ]
            ],
        });


        // 定义全局变量
        var mainIndex;

        // 打开添加款项任务得弹出层
        function openAddKWTask(data) {
            console.log(data);
            $.post("/KW/KW_NAMELIST", {pay_CODE: data}, function (res) {
                if (res.code == 0) {
                    mainIndex = layer.open({
                        type: 1,
                        title: '款项任务添加',
                        content: $("#addKWTask"),
                        area: ['60%', '40%'],
                        success: function (index) {
                            var KW_NAMELIST = table.render({
                                elem: '#KW_NAMELIST',
                                url: '/KW/KW_NAMELIST1',
                                //toolbar: 'default', //  默认的头工具栏事件
                                cellMinWidth: 110, //全局定义常规单元格的最小宽度，layui 2.2.1 新增
                                cols: [
                                    [{
                                        field: 'kw_ID',
                                        title: '任务(款项)编号',
                                        align: "center",
                                        width: "13%"
                                    },
                                        {
                                            field: 'kw_CODE',
                                            title: '款项ID',
                                            align: "center",
                                            width: "10%"
                                        },
                                        {
                                            field: 'kw_NAME',
                                            title: '任务(款项)名称',
                                            align: "center",
                                            width: "17%"
                                        },
                                        {
                                            field: 'task_RESPONER',
                                            title: '责任人',
                                            align: "center",
                                            edit: "text",
                                            width: "10%"
                                        },
                                        {
                                            field: 'kw_TYPE',
                                            title: '任务类型',
                                            align: "center",
                                            width: "10%"
                                        },
                                        {
                                            field: 'kw_CLASS',
                                            title: '款项类型',
                                            align: "center",
                                            width: "10%"
                                        },
                                        {
                                            field: 'kw_CONTENT',
                                            title: '前置任务',
                                            align: "center",
                                            width: "20%"
                                        },
                                        {
                                            fixed: 'right',
                                            title: '操作',
                                            width: "10%",
                                            align: 'center',
                                            toolbar: '#barDemo2'
                                        }
                                    ]
                                ],
                            });
                            //$("#KWTaskForm")[0].reset();
                        }
                    });
                }
            })
        }

        //查看款项任务的弹出层
        function checkKWTask(data){
            $.post("/KW/CheckKWTask", {
                PAY_PRJCODE: data.pay_PRJCODE,
                PAY_ID: data.pay_ID,
                PAY_CODE: data.pay_CODE
            }, function (res) {
                if (res.code == 0) {
                    mainIndex = layer.open({
                        type: 1,
                        title: '款项任务查看',
                        content: $("#addKWTask"),
                        area: ['60%', '40%'],
                        success: function (index) {
                            var KW_NAMELIST = table.render({
                                elem: '#KW_NAMELIST',
                                url: '/KW/CheckKWTask1',
                                //toolbar: 'default', //  默认的头工具栏事件
                                cellMinWidth: 110, //全局定义常规单元格的最小宽度，layui 2.2.1 新增
                                cols: [
                                    [{
                                        field: 'tk_PRJCode',
                                        title: '任务(款项)编号',
                                        align: "center",
                                        width: "13%"
                                    },
                                        {
                                            field: 'tk_CODE',
                                            title: '款项ID',
                                            align: "center",
                                            width: "10%",
                                        },
                                        {
                                            field: 'tk_NAME',
                                            title: '任务(款项)名称',
                                            align: "center",
                                            width: "17%",
                                        },
                                        {
                                            field: 'tk_RESPONER',
                                            title: '责任人',
                                            align: "center",
                                            edit: "text",
                                            width: "10%",
                                            templet:"<div>{{d.tk_RESPONER == null ? 'NO' : d.tk_RESPONER}}</div>"
                                        },
                                        {
                                            field: 'tk_TaskType',
                                            title: '任务类型',
                                            align: "center",
                                            width: "10%"
                                        },
                                        {
                                            field: 'kw_CLASS',
                                            title: '款项类型',
                                            align: "center",
                                            width: "10%"
                                        },
                                        {
                                            field: 'tk_PreTask',
                                            title: '前置任务',
                                            align: "center",
                                            width: "20%"
                                        },
                                        {
                                            fixed: 'right',
                                            title: '操作',
                                            width: "10%",
                                            align: 'center',
                                            toolbar: '#barDemo2'
                                        }
                                    ]
                                ],
                            });
                        }
                    });
                }
            })
        }


        form.on('select(selectCLASS)', function (data) {
            value = data.value
            console.log(value)
            $.post("/KW/KWSelectKW_NAME", {
                value: value
            }, function (res) {
                if (res.code == 0) {
                    layer.msg(res.msg, {icon: 1}, {timeout: 3000});
                    var select_kw_NameSelect = $(".KW_NAMESelect");
                    var html = "";
                    var data = res.data;
                    $.each(data, function (index, item) {
                        html += "<option value =" + item.kw_ID + ">" + item.kw_NAME + "</option>";
                    });
                    select_kw_NameSelect.html(html);
                    // 重新初始化 下拉框 要不然 数据显示不出来
                    form.render("select");
                } else if (res.code == -1) {
                    layer.msg(res.msg, {icon: 3}, {timeout: 3000});
                }
            })
        })

        // 加载款项类型下拉框信息
        $.get("/KW/KWSelectKW_CLASS", function (res) {
            // 获取下拉框
            var select_kw_CLASSSelect = $(".KW_CLASSSelect");
            var html = "<option value =''>请选择类型</option>";
            var data = res.data;
            $.each(data, function (index, item) {
                html += "<option value =" + item.kw_CODE + ">" + item.kw_CLASS + "</option>";
            });
            select_kw_CLASSSelect.html(html);
            // 重新初始化 下拉框 要不然 数据显示不出来
            form.render("select");
        });

        //加载款项名称下拉框信息

        //监听添加款项按钮
        form.on("submit(add-KW-btn)", function (data) {
            var btn = $(this);
            btn.text("提 交 中...").attr("disabled", "disabled").addClass("layui-disabled");
            var params = $("#KWForm").serialize();
            $.post("", params, function (res) {
                layer.msg(res.msg);
                if (res.code == 0) {
                    btn.text("提交").attr("disabled", "").removeClass("layui-disabled");
                    tableIns.reload();
                }
            })
            return false;
        })

        //添加款项
        function insertKW(PAY_PRJCODE, PAY_CODE, PAY_CLASS, PAY_AMOUNT) {
            $.ajax({
                type: "post",
                url: "/KW/payMents",
                data: {
                    PAY_PRJCODE: PAY_PRJCODE,
                    PAY_CODE: PAY_CODE,
                    PAY_NAME: PAY_CLASS,
                    PAY_AMOUNT: PAY_AMOUNT
                },
                success: function (res) {
                    if (res.code == 0) {
                        layer.msg(res.msg, {icon: 1, time: 2000}, function () {
                            tableIns.reload();
                            KWTaskTable.reload();
                        });
                    } else {
                        layer.msg(res.msg);
                    }
                }
            });
        }


        //监听行工具事件
        table.on('tool(KWList)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
            var data = obj.data, //获得当前行数据
                layEvent = obj.event; //获得 lay-event 对应的值
            let val = $("#PO_PRJCODE").val();
            if (layEvent === 'addKW') {
                if (data.kw_MONEY == null) {
                    layer.msg("请输入款项金额");
                } else {
                    insertKW(val, data.kw_CODE, data.kw_CLASS, data.kw_MONEY);
                }
            }
        });

        table.on('tool(KWTask)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
            var data = obj.data, //获得当前行数据
                layEvent = obj.event; //获得 lay-event 对应的值
            let val = $("#PO_PRJCODE").val();
            if (layEvent === 'addTask') {
                //alert(JSON.stringify(data));
                layer.msg('添加任务');
                openAddKWTask(data.pay_CODE);
                /* if (data.kw_MONEY == null) {
                     layer.msg("请输入款项金额");
                 } else {
                     insertKW(val, data.kw_CODE, data.kw_CLASS, data.kw_MONEY);
                 }*/
            }else if (layEvent === 'checkTask'){
                layer.msg('查看任务')
                checkKWTask(data);
            }
        });

        table.on('tool(KW_NAMELIST)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
            var data = obj.data, //获得当前行数据
                layEvent = obj.event; //获得 lay-event 对应的值
            if (layEvent === 'confirm') {
                layer.confirm('确定？' , {icon:3},function(){
                    $.post("/KW/addKWTask", {
                        kw_ID : data.kw_ID,
                        kw_CODE : data.kw_CODE,
                        kw_NAME : data.kw_NAME,
                        kw_TYPE : data.kw_TYPE,
                        kw_CLASS : data.kw_CLASS,
                        kw_CONTENT : data.kw_CONTENT,
                        task_RESPONER : data.task_RESPONER
                    }, function (res) {
                        if (res.code == 0) {
                            layer.msg(res.msg, {icon: 1}, {timeout: 3000});
                            //tableIns.reload();
                        } else if (res.code == -1) {
                            layer.msg(res.msg, {icon: 3}, {timeout: 3000});
                        }
                    })
                });
            }
        });




        table.on('edit(KWList)', function (obj) {
            var value = obj.value //得到修改后的值
                , data = obj.data //得到所在行所有键值
                , field = obj.field; //得到字段
            if (value <= ${orders.PO_SUMS}) {
                layer.msg('尹家浩提示您：[款项编号为: ' + data.kw_CODE + '] ' + '中的，[款项金额被修改为：' + value + ']', {
                    icon: 1,
                    time: 3000
                })
                /*layer.confirm('尹家浩提示您：[款项编号为：' + data.kw_CODE + '] ' + '中的，[款项金额被修改为：' + value + '] ' , {icon:1},function(){
                    $.post("/KW/payMentsTotal", {
                        value:value
                    }, function (res) {
                        if (res.code == 0) {
                            layer.msg(res.msg, {icon: 1}, {timeout: 3000});
                            tableIns.reload();
                        } else if (res.code == -1) {
                            layer.msg(res.msg, {icon: 3}, {timeout: 3000});
                        }
                    })
                });*/
            } else {
                //layer.msg('尹家浩提示您：[款项编号为: ' + data.kw_CODE + '] ' + '中的，[款项金额被修改为：' + value + ']');
                layer.msg("您输入的数据大于合同金额，请重新输入");
                tableIns.reload();
            }
        });

        table.on('edit(KW_NAMELIST)', function (obj) {
            var value = obj.value //得到修改后的值
                , data = obj.data //得到所在行所有键值
                , field = obj.field; //得到字段
            console.log(JSON.stringify(data))
            layer.msg('尹家浩提示您：是否指定' + '[' + data.kw_NAME + '] ' + '这个任务的负责人为：' + '[' + value + '] ' + '请点击添加按钮确定' , {icon:3});
        });

        //选中后的回调
        laydate.render({
            elem: '#TK_START_DATE'
            , done: function (value, date) {
                /*layer.alert('你选择的日期是：' + value + '<br>获得的对象是' + JSON.stringify(date));*/
            }
            , theme: "molv"
        });

        laydate.render({
            elem: '#TK_END_DATE'
            , done: function (value, date) {
                /*layer.alert('你选择的日期是：' + value + '<br>获得的对象是' + JSON.stringify(date));*/
            }
            , theme: "molv"
        });
        form.render();
    });
</script>
